#!/usr/bin/env python3

'''
Created on Apr 6, 2011

@author: ArchyBen
'''

from decimal import getcontext
from decimal import Decimal

def euler80():
  """
  For the first one hundred natural numbers, find the total of the digital sums of the first one hundred decimal digits for all the irrational square roots
  """
  #FIXME The last decimal is rounded, not truncated
  getcontext().prec = 105
  res = 0
  for value in range(1,100):
    dec = Decimal(value).sqrt()
    if dec._isinteger():
      continue 
    dec2str = str(dec)
    #dec2str = dec2str[2:]
    print("{} : {}. nbdigit : {}".format(value,dec2str,len(dec2str)))
    for digit in dec2str[:-5]:
      if digit.isdigit():
        res += int(digit)
    print(res)
  return res

if __name__ == '__main__':
  print(euler80())
